package com.dhl.prototypepattern.prototype.deepcopy;

/**
 * @title: ShallowTom
 * @Author danghailiang
 * @Date: 2022/7/28 21:16
 * @Version 1.0
 */
public class DeepTom implements Cloneable {
    private Long id;
    private String name;
    private DeepYang deepYang;

    public DeepYang getDeepYang() {
        return deepYang;
    }

    public void setDeepYang(DeepYang deepYang) {
        this.deepYang = deepYang;
    }

    public DeepTom(Long id, String name, DeepYang deepYang) {
        this.id = id;
        this.name = name;
        this.deepYang = deepYang;
    }

    public DeepTom() {
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "DeepTom{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", deepYang=" + deepYang +
                '}';
    }

    /**
     * 克隆对象
     * @return
     */
    @Override
    public DeepTom clone() throws CloneNotSupportedException {
        DeepTom deepTom = (DeepTom) super.clone();
        deepTom.deepYang = (deepTom.getDeepYang().clone());
        return deepTom;
    }
}
